/**
 * Created by Administrator on 2017/4/7.
 */

    //获取的ID

var OrderId = window.data.id;
var carId;
var carStatus;
var OrderDtat;
$(function () {
    var findCarID = '';
    //----只需再orderStatus函数传入id----//
    breakRules(OrderId);
    function findCar(vehicle, status) {
        $(".CarInformation").html('');
        // console.log(vehicle);
        var arguments = {
            id: vehicle
        };
        $.ajax({
            url: ctx + '/rentcar/findById',
            type: "GET",
            data: arguments,
            async:false,
            success: function (data) {
                var obj = eval('(' + data.data + ')'); //由JSON字符串转换为JSON对象
                var argument = {
                    id: obj.rentCar.shopId
                };
                $.ajax({
                    url: ctx + '/rentshop/selectRentshop',
                    type: "GET",
                    data: argument,
                    success: function (data1) {
                        // console.log(data1);
                        var findCarOption = {
                            data: {
                                Thead: {
                                    vehicleName: "车辆名称",
                                    rent: "车辆租金",
                                    deposit: "违约租金",
                                    PreLicensing: "预授权",
                                    brand: "品牌",
                                    plateNumber: "车牌号",
                                    ownedStores: "所属门店",
                                    gearBox: "变速箱",
                                    carType: "车型",
                                    displacement: "排量",
                                    seats: "座位数",
                                    roadHaul: "行驶里程",
                                    location: "所在地",
                                    trafficControl: "限行"
                                },
                                Tbody: []
                            }

                        };
                        var item = {
                            vehicleName: obj.rentCar == null ? "无" : obj.rentCar.carName,
                            rent: obj.vehicle.rent == null ? "0" : obj.vehicle.rent,
                            deposit: obj.vehicle.illegalDeposit == null ? "0" : obj.vehicle.illegalDeposit,
                            PreLicensing: obj.vehicle.pregrant == null ? "0" : obj.vehicle.pregrant,
                            brand: obj.vehicle.brandName == null ? "无" : obj.vehicle.brandName,
                            plateNumber: obj.car.plateNo == null ? "无" : obj.car.plateNo,
                            ownedStores: obj.rentCar.shopName == null ? "无" : obj.rentCar.shopName,
                            gearBox: obj.vehicle.transmission == null ? "无" : obj.vehicle.transmission,
                            carType: obj.vehicle.type == null ? "未知" : obj.vehicle.type,
                            displacement: obj.vehicle.displacement == null ? "未知" : obj.vehicle.displacement,
                            seats: obj.vehicle.seat == null ? "无" : obj.vehicle.seat,
                            roadHaul: obj.car.mileage == null ? "暂无信息" : obj.car.mileage,
                            location: data1.address == null ? "暂无信息" : data1.address,
                            trafficControl: ''
                        };


                        switch (obj.rentCar.limit) {
                            case 0:
                                item.trafficControl= "不限行";
                                break;
                            case 1:
                                item.trafficControl="星期一";
                                break;
                            case 2:

                                item.trafficControl="星期二";
                                break;
                            case 3:
                                item.trafficControl="星期三";
                                break;
                            case 4:
                                item.trafficControl="星期四";
                                break;
                            case 5:
                                item.trafficControl="星期五";
                                break;
                            case 6:
                                item.trafficControl="星期六";
                                break;
                            case 7:
                                item.trafficControl="星期日";
                                break;
                        }

                        if (status == 10) {
                            // console.log(123123);
                            findCarOption.data.Thead['action'] = '修改车辆';
                            var fenpei=$('<span></span>');
                            fenpei.ActionButtons({
                                data: '修改车辆', onChange: function () {
                                    function dispatchCar(data) {
                                        var QuCar = {
                                            data: {
                                                Title: '分配车辆',
                                                Content: '',
                                                OkChange: function () {
                                                    $.ajax({
                                                        url: ctx + '/rentorder/dispatchCar',
                                                        data: {
                                                            id: data.id,
                                                            carId: $('.CustomModalBox').data('carId'),
                                                            plateNo: $('.CustomModalBox').data('plateNo'),
                                                            vehicle: $('.CustomModalBox').data('vehicle')
                                                        },
                                                        type: 'POST',
                                                        success: function (data) {
                                                            if (data.message == '派车成功') {
                                                                $('body').Overlays({data: {text: '派车成功！', state: 'Ok'}});
                                                                orderStatus(OrderId);
                                                            } else {
                                                                $('body').Overlays({data: {text: '派车失败，请稍后重试！', state: 'No'}});
                                                                orderStatus(OrderId);
                                                            }
                                                        }
                                                    })
                                                }
                                            }
                                        };
                                        var limit = 10;
                                        var brandId = '';
                                        var plateNo = '';
                                        var vehicleId = data.vehicle;
                                        var shopID = data.shopId;
                                        var allotCar = $('<div class="allotCar"></div>');
                                        allotCar.append('<div class="allotCarNav"><span>品牌-车系：</span><input type="text" class="carType" placeholder="点击选择品牌及车系" readonly><span>车牌号：</span><input class="plateNo" type="text" placeholder="请输入车牌号"><span class="ActionSEO"></span></div><div class="allotCarOrder"></div>');
                                        $.ajax({
                                            url: ctx + '/rentcontent/selectContentByPid',
                                            data: {
                                                pid: 4
                                            },
                                            success: function (data) {
                                                var brandSelect = {
                                                    data: [],
                                                    onChange: function () {
                                                    }
                                                };
                                                for (var i = 0; i < data.length; i++) {
                                                    (function () {
                                                        var index = i;
                                                        brandSelect.data.push({name: data[index].contentName, Val: data[index].id})
                                                    })()
                                                }
                                                allotCar.find('.brandSelect').DownPullSelect(brandSelect)
                                            }
                                        });
                                        allotCar.find('.carType').on('click', function () {
                                            var vehicleIdOption = {
                                                data: {
                                                    Title: '选择车系',
                                                    Content: '',
                                                    OkChange: function (e, Remove) {
                                                        if (allotCar.find('.carType').data('data')) {
                                                            var data = allotCar.find('.carType').data('data');
                                                            brandId = data.CarBrandId;
                                                            vehicleId = data.vehicleId;
                                                            allotCar.find('.carType').val(data.CarBrandName + ' - ' + data.CarSeriesName);
                                                            Remove()
                                                        } else {
                                                            $('body').Overlays({data: {text: '请选择一个车系！', state: 'No'}})
                                                        }
                                                    }
                                                },
                                                OKHide: true
                                            };
                                            var vehicleIdContent = $('<div class="vehicleIdContent"></div>');
                                            $.ajax({
                                                url: ctx + '/rentcontent/selectContentByPid',
                                                data: {
                                                    pid: 4
                                                },
                                                type: 'GET',
                                                success: function (data) {
                                                    if (data.length > 0) {
                                                        for (var i = 0; i < data.length; i++) {
                                                            (function () {
                                                                var index = i;
                                                                var val = $('<div class="Brand"></div>').html('<div class="BrandName">' + data[index].contentName + '</div><div class="Vehicle CustomClear"></div>');
                                                                var Id = data[index].id;
                                                                var Name = data[index].contentName;
                                                                $.ajax({
                                                                    url: ctx + '/rentvehicle/findVehicleByparams',
                                                                    data: {
                                                                        shopId: shopID,
                                                                        brandId: data[index].id
                                                                    },
                                                                    type: 'GET',
                                                                    success: function (data) {


                                                                        if(data.content.length>0){
                                                                            for (var i = 0; i < data.content.length; i++) {
                                                                                (function () {
                                                                                    var index = i;
                                                                                    var item = $('<label class="CustomClear"></label>');
                                                                                    item.append('<input type="radio" name="Vehicle" value="' + data.content[i].id + '"><span>' + data.content[i].name + '</span>');
                                                                                    item.on('click', function () {
                                                                                        var datas = {
                                                                                            vehicleId: data.content[index].id,
                                                                                            CarSeriesId: data.content[index].id,
                                                                                            CarSeriesName: data.content[index].name,
                                                                                            CarBrandId: Id,
                                                                                            CarBrandName: Name
                                                                                        };
                                                                                        allotCar.find('.carType').data('data', datas)
                                                                                    });
                                                                                    val.find('.Vehicle').append(item)
                                                                                })()
                                                                            }
                                                                        }else {
                                                                            val.find('.Vehicle').append('此品牌下未添加车系！')
                                                                        }

                                                                    }
                                                                });
                                                                vehicleIdContent.append(val)
                                                            })()
                                                        }
                                                    }
                                                }
                                            });
                                            vehicleIdOption.data.Content = vehicleIdContent;
                                            $('body').ModalBox(vehicleIdOption);
                                        });
                                        allotCar.find('.ActionSEO').ActionButtons({
                                            data: '查询', onChange: function () {
                                                plateNo = allotCar.find('.plateNo').val();
                                                CarOrder(1, brandId, plateNo, shopID, vehicleId);
                                            }
                                        });
                                        function CarOrder(page, brandId, plateNo, shopID, vehicleId) {
                                            $.ajax({
                                                url: ctx + '/rentcar/findByBrandIdAndPlateNo',
                                                data: {
                                                    brandId: brandId,
                                                    plateNo: plateNo,
                                                    shopId: shopID,
                                                    vehicleId: vehicleId,
                                                    limit: limit,
                                                    'pager.offset': (page - 1) * limit
                                                },
                                                success: function (data) {
                                                    var allotCarOrder = {
                                                        data: {
                                                            Thead: {
                                                                action: '选择',
                                                                name: '车辆名称',
                                                                rent: '租金',
                                                                deposit: '押金',
                                                                brand: '品牌',
                                                                plateNo: '车牌号',
                                                                shopName: '门店',
                                                                transmission: '变速箱',
                                                                type: '车型',
                                                                displacement: '排量',
                                                                seat: '座位数',
                                                                limit: '限行'
                                                            },
                                                            Tbody: []
                                                        }
                                                    };
                                                    for (var i = 0; i < data.content.length; i++) {
                                                        (function () {
                                                            var index = i;
                                                            var val = {
                                                                action: '',
                                                                name: data.content[index].rentCar.carName,
                                                                rent: data.content[index].vehicle.rent,
                                                                deposit: data.content[index].vehicle.illegalDeposit,
                                                                brand: data.content[index].vehicle.brandName,
                                                                plateNo: data.content[index].car.plateNo,
                                                                shopName: data.content[index].rentCar.shopName,
                                                                transmission: data.content[index].vehicle.transmission,
                                                                type: data.content[index].vehicle.type,
                                                                displacement: data.content[index].vehicle.displacement,
                                                                seat: data.content[index].vehicle.seat,
                                                                limit: data.content[index].rentCar.limit
                                                            };

                                                            switch (data.content[index].rentCar.limit){
                                                                case 0:
                                                                    val.limit='不限行';
                                                                    break;
                                                                case 1:
                                                                    val.limit='星期一';
                                                                    break;
                                                                case 2:
                                                                    val.limit='星期二';
                                                                    break;
                                                                case 3:
                                                                    val.limit='星期三';
                                                                    break;
                                                                case 4:
                                                                    val.limit='星期四';
                                                                    break;
                                                                case 5:
                                                                    val.limit='星期五';
                                                                    break;
                                                                case 6:
                                                                    val.limit='星期六';
                                                                    break;
                                                                case 7:
                                                                    val.limit='星期日';
                                                                    break;
                                                            }

                                                            var RadioActionButtonsOption = $('<span class="RadioActionButtonsOption"></span>');
                                                            RadioActionButtonsOption.RadioActionButtons({
                                                                data: {
                                                                    name: 'allotCar'
                                                                },
                                                                onChange: function () {
                                                                    $('.CustomModalBox').data({
                                                                        'carId': data.content[index].rentCar.id,
                                                                        'plateNo': data.content[index].car.plateNo,
                                                                        'vehicle': data.content[index].vehicle.id
                                                                    })
                                                                }
                                                            });
                                                            val.action = RadioActionButtonsOption;
                                                            allotCarOrder.data.Tbody.push(val)
                                                        })()
                                                    }
                                                    allotCar.find('.allotCarOrder').Order(allotCarOrder);
                                                    var PagingMdOption = {
                                                        data: {
                                                            rows: limit,
                                                            nowrows: page,
                                                            Pages: '',
                                                            total: data.totalElements,
                                                            change: function (index) {
                                                                CarOrder(index, 1, '');
                                                            }
                                                        }
                                                    };
                                                    allotCar.find('.allotCarOrder').PagingMd(PagingMdOption)
                                                }
                                            });
                                        }
                                        CarOrder(1, brandId, plateNo, shopID, vehicleId);
                                        QuCar.data.Content = allotCar;
                                        $('body').ModalBox(QuCar);
                                    }
                                    dispatchCar(OrderDtat)
                                }
                            });
                            item['action'] =fenpei;

                        }
                        findCarOption.data.Tbody.push(item);

                        $(".CarInformation").Order(findCarOption);

                    }
                });

            }
        })
    }

    function CarAndSettlement(id) {
        var arguments = {
            orderId: id
        };
        $.ajax({
            url: ctx + '/rentorder/selectRentOrderStatus',
            type: "GET",
            data: arguments,
            async:false,
            success: function (data) {
                var TraceInformationOption = {
                    data: []
                };
                for (var i = 0; i < data.length; i++) {
                    TraceInformationOption.data.push(data[i]);
                }
                $(".traceInformation").find(".CustomTrace").remove();
                $(".traceInformation").TraceInformation(TraceInformationOption);

            }
        })
    }

    function orderStatus(id) {
        var arguments = {
            id: id
        };
        $.ajax({
            url: ctx + '/rentorder/selectRentOrder',
            type: "GET",
            data: arguments,
            async:false,
            success: function (data) {
                // console.log(data)
                findCarID = data.carId;
                data.state = [
                    {stateName: "客户下单"},
                    {stateName: "已确认"},
                    {stateName: "服务中"},
                    {stateName: "已还车"},
                    {stateName: "已完成"}
                ];
                carId=data.carId;
                carStatus=data.status;
                OrderDtat=data;
                if(!data.status==0 && !data.status==5 && !data.status==-5){
                    findCar(data.carId, data.status);
                }


                $(".OrderStatus").html('');
                $(".OrderStatus").OrderStatus(data);

                //--订单信息=------------//
                var dingdan='<h4>订单信息</h4>'
                var dingdanhao = '<div>' + '<span>订单号:</span><p class="orderNo">' + (data.orderNo) + '</p></div>';
                var quche = '<div>' + '<span>取车地址:</span>' + (data.takeCarWay == 1 ? data.startAddress : "门店自取") + '</div>';
                var huanche = '<div>' + '<span>还车地址:</span>' + (data.backCarWay == 1 ? data.endAddress : '门店自还') + '</div>';
                var a = '<div>' + '<span>预约时间:</span>' + (data.bookTime ? $.fn.Timestamp.TimestampDate(data.bookTime) : "暂未信息") + '</div>';
                // var b = '<div>' + '<span>订单类型:</span>'+'2222'+'</div>';
                var c = '<div>' + '<span>预计还车时间:</span>' + (data.rentTime ? $.fn.Timestamp.TimestampDate(data.rentTime) : "暂无") + '</div>';
                var d = '<div>' + '<span>实际还车时间:</span>' + (data.backCarTime ? $.fn.Timestamp.TimestampDate(data.backCarTime) : "暂无") + '</div>';
                var f = '<div>' + '<span>客户姓名:</span>' + (data.passengerName ? data.passengerName : "暂无") + '</div>';
                var g = '<div><span>客户电话:</span>'+(data.passengerPhone ? data.passengerPhone : "暂无")+'</div>';
                //--付款信息------------//
                var fukuanxinxi='<h4>付款信息</h4>'
                var h = '<div><span>租金:</span><span class="yang">￥' + (data.rentFee ? data.rentFee : 0) + '</span>元' + '</div>';
                var i = '<div><span>违章押金:</span><span class="yang">￥' + (data.peccancyForegift ? data.peccancyForegift : 0) + '</span>元' + '</div>';
                var pry = '<div><span>租车押金:</span><span class="yang">￥' + (data.prepayRent ? data.prepayRent : 0) + '</span>元' + '</div>';
                var weiyue = '<div><span>违约金:</span><span class="yang">￥' + (data.violationFee ? data.violationFee : 0) + '</span>元' + '</div>';
                var weizhang = '<div><span>违章费:</span><span class="yang">￥' + (data.peccancyFee ? data.peccancyFee : 0) + '</span>元' + '</div>';
                var j = '<div><span>加油费:</span><span class="yang">￥' + (data.gasFee ? data.gasFee : 0) + '</span>元' + '</div>';
                var k = '<div><span>不计免赔:</span><span class="yang">￥' + (data.noDeductible ? data.noDeductible : 0) + '</span>元' + '</div>';
                var l = '<div><span>配司机:</span><span class="yang">￥' + (data.driverFee ? data.driverFee : 0) + '</span>元' + '</div>';
                var m = '<div><span>儿童安全座椅:</span><span class="yang">￥' + (data.safetySeatFee ? data.safetySeatFee : 0) + '</span>元' + '</div>';
                var n = '<div><span>基本保险费:</span><span class="yang">￥' + (data.insurance ? data.insurance : 0) + '</span>元' + '</dasync:flase,>';
                var aa = '<div><span>上门送车费:</span><span class="yang">￥' + (data.takeCarFee ? data.takeCarFee : 0) + '</span>元' + '</div>';
                var bb = '<div><span>上门取车费:</span><span class="yang">￥' + (data.backCarFee ? data.backCarFee : 0) + '</span>元' + '</div>';
                var p = '<div><span>异地还车:</span><span class="yang">￥' + (data.remoteBackFee ? data.remoteBackFee : 0) + '</span>元' + '</div>';
                var q = '<div><span>续租费:</span><span class="yang">￥' + (data.reRentFee ? data.reRentFee : 0) + '</span>元' + '</div>';
                var r = '<div><span>GPS费:</span><span class="yang">￥' + (data.gpsFee ? data.gpsFee : 0) + '</span>元' + '</div>';
                var t = '<div><span>已支付:</span><span class="yang">￥' + (data.payed ? data.payed : 0) + '</span>元' + '</div>';
                var counterFees = '<div><span>手续费:</span><span class="yang">￥' + (data.counterFee ? data.counterFee : 0) + '</span>元' + '</div>';
                var chaoshiziduan = '<div><span>超时费:</span><span class="yang">￥' + (data.overtimeFee ? data.overtimeFee : 0) + '</span>元' + '</div>';
                var otherziduan = '<div><span>其他费用:</span><span class="yang">￥' + (data.otherFee ? data.otherFee : 0) + '</span>元' + '</div>';
                var dingshunziduan = '<div><span>定损费:</span><span class="yang">￥' + (data.assessFee ? data.assessFee : 0) + '</span>元' + '</div>';
                var s = '<div><span>合计:</span><span class="yang">￥' + (data.totalFee ? data.totalFee : 0) + '</span>元' + '</div>';

                // if (data.prepayRentType == '0') {
                //     var u = '<div><span>租车押金:</span>' + data.prepayRent + '元' + '</div>';
                // } else if (data.prepayRentType == '1') {
                //     u = '<div><span>租车押金:</span>' + data.prepayRent + '元' + '</div>';
                //     var v = '<div><span>租金预授权到期:</span>' + $.fn.Timestamp.TimestampDate(data.prepayRentTime) + '</div>';
                // }
                //
                // // console.log(data)
                // if (data.peccancyForegiftType == '0') {
                //     var w = '<div><span>违章押金:</span>' + data.peccancyForegift + '元' + '</div>';
                // } else if (data.peccancyForegiftType == '1') {
                //     w = '<div><span>违章押金:</span>' + data.peccancyForegift + '元' + '</div>';
                //     var x = '<div><span>违章预授权到期:</span>' + $.fn.Timestamp.TimestampDate(data.peccancyForegiftTime) + '</div>';
                // }
                // var y =  "<label>预授额度<span>￥3000.00</span></label><label>应退还预授额度<span>￥200.00</span><button type='button'></button>'</label>'+'<br>'
                //
                //           + '<label>'+违章押金+'<span>'+￥3000.00+'</span></label><label>应退还违章'<span>'+￥200.00+'</span>'+'<button type="button"></button>'+"</label>"
                $(".orderinformation").find(".needMoney");
                $(".OrderInformation").find(".right").html('')
                $(".OrderInformation").find(".right").append(fukuanxinxi,h, j, k, l, m, n, p, q, r, weiyue, weizhang, counterFees, chaoshiziduan, otherziduan, aa, bb, dingshunziduan, s, t);
                $(".OrderInformation").find(".left").html('')
                $(".OrderInformation").find(".left").append(dingdan,dingdanhao,quche,huanche,a, c, d, f,g, i, pry);
                if (!data.isBackPeccancyForegift == 2) {
                    var peccancy = data.peccancyForegift;
                    var peccancyForegift = $("<div class='peccancyForegift'>违章预授额度:￥<span class='peccancy'></span><button class='button11' type='button'>退还违章押金</button></div>");
                    $(".GivenBeforehand").append(peccancyForegift);
                    $(".peccancy").text(peccancy);
                    $(document).on('click', ".button11", function () {
                        var options = {
                            data: {
                                Title: "温馨提示",
                                Content: "确认退还违章押金？",
                                OkChange: function () {
                                    var arguments = {
                                        id: OrderId,
                                        type: 1
                                    };
                                    $.ajax({
                                        url: ctx + '/rentorder/backForegift',
                                        type: "POST",
                                        data: arguments,
                                        success: function (data) {
                                            if (data.message == "退还成功") {
                                                $("body").Overlays({data: {text: data.message, state: 'Ok'}})
                                            } else {
                                                $("body").Overlays({data: {text: data.message, state: 'No'}})
                                            }
                                        }
                                    })
                                }
                            }
                        };
                        $("body").ModalBox(options);
                    })
                }
                if (!data.isBackPrepayRent == 2) {
                    var prepayRent = data.prepayRent;
                    var prepay = $("<div class='prepayRent'>租车预授额度:￥<span class='prepay'></span><button type='button' class='button22'>退还租车押金</button></div>")
                    $(".GivenBeforehand").append(prepay);
                    $(".prepay").text(prepayRent);
                    $(document).on('click', '.button22', function () {
                        var options = {
                            data: {
                                Title: "温馨提示",
                                Content: "确认退还租金押金？",
                                OkChange: function () {
                                    var arguments = {
                                        id: OrderId,
                                        type: 0
                                    };
                                    $.ajax({
                                        url: ctx + '/rentorder/backForegift',
                                        type: "POST",
                                        data: arguments,
                                        success: function (data) {
                                            if (data.message == "退还成功") {
                                                $("body").Overlays({data: {text: data.message, state: 'Ok'}})
                                            } else {
                                                $("body").Overlays({data: {text: data.message, state: 'No'}})
                                            }
                                        }
                                    })
                                }
                            }
                        };
                        $("body").ModalBox(options);
                    })
                }
                $(".OrderStatus").find("CustomOrderStatus").remove();

            }
        })
    }

    function breakRules(id) {
        var arguments = {
            orderId: id
        };
        $.ajax({
            url: ctx + '/rentorder/selectPeccancysByOrderId',
            type: "GET",
            data: arguments,
            success: function (data) {
                var EndorsementOption = {
                    data: {
                        Thead: {b: "违章时间", k: "违章地点", c: "违章分数", d: "违章罚款(元)", e: "违章描述", f: "通知客户"},
                        Tbody: []
                    }
                };

                for (var i = 0; i < data.length; i++) {
                    (function () {
                        var index = i;
                        var Val = {
                            b: $.fn.Timestamp.TimestampDate(data[i].time),
                            k: data[i].address,
                            c: data[i].deductMarks,
                            d: data[i].amerce,
                            e: data[i].reason,
                            ButtonAction: {
                                name: "处理",
                                Action: function () {
                                    var chuliSate = true;

                                    function chulifn() {
                                        if (chuliSate) {
                                            chuliSate = false;
                                            var timestamp = (new Date()).valueOf();
                                            var Dispose = {
                                                data: {
                                                    Title: '处理违章',
                                                    Content: '确认这个违章已处理？',
                                                    OkChange: function (e) {
                                                        $.ajax({
                                                            url: ctx + '/rentorder/postPeccancy',
                                                            data: {
                                                                id: data[index].id,
                                                                status: 1
                                                            },
                                                            type: 'POST',
                                                            success: function (data) {
                                                                if (data.message == '修改状态成功') {
                                                                    $('body').Overlays({
                                                                        data: {
                                                                            text: '处理违章成功！',
                                                                            state: 'Ok'
                                                                        }
                                                                    });
                                                                    breakRules(id);
                                                                } else {
                                                                    $('body').Overlays({
                                                                        data: {
                                                                            text: '处理违章失败，请稍后重试！',
                                                                            state: 'No'
                                                                        }
                                                                    })
                                                                }
                                                            }
                                                        });


                                                    }
                                                }
                                            };
                                            $('body').ModalBox(Dispose)
                                        }
                                    }

                                    chulifn()
                                }
                            }
                        };
                        if (data[i].status == 1) {
                            Val.ButtonAction = '已处理'
                        }
                        // console.log(data[i]);
                        EndorsementOption.data.Tbody.push(Val);
                    })();

                }
                (function () {
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].status == 1) {
                            chuliSateAll = true;
                        } else {
                            chuliSateAll = false;
                            return;
                        }
                    }
                })();

                $(".Endorsement").find(".OrderTable").remove();
                $(".Endorsement").Order(EndorsementOption);
            }
        })

    }
    orderStatus(OrderId);
    CarAndSettlement(OrderId);

    //-----点击返回跳转-------//
    $(".AnNiu").find("button").on("click", function () {
        window.history.back(-1);
    });
    /**选项卡**/
    $(".cont").find(".tab").eq(0).show();
    $(".tabs").find("li").each(function (index) {
        $(this).on("click", function () {
            $(this).addClass("TabAcLine");
            $(this).siblings().removeClass("TabAcLine");
            $(".cont .tab").eq(index).show();
            $(".cont .tab").eq(index).siblings().hide()
        })
    })

    for(var i=0;i<$('input[type="number"]').length;i++){
        (function () {
            var index=i;
            $('input[type="number"]').eq(index).on('change',function () {
                if($(this).val()<0){
                    $(this).val(0)
                }
            })
        })()
    }
});



